package sui.utils.regex;

import java.util.regex.Pattern;

public class regexUtils {

	public static final String BIRTH_DATE_REG = "([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-9])))";
	public static final String CHINESE = "[\\\\u4e00-\\\\u9fff]";
	
	
	public static int length(String reg, String message) {
		return message.split (reg).length - 1;
	}
	
	public static boolean matcher(String reg, String message) {
		return Pattern.compile(reg).matcher(message).matches();
	}
	
	public static void main(String[] args) {
		System.out.println(length(CHINESE, "slh啊阿红11sda"));
		System.out.println(matcher(BIRTH_DATE_REG, "1985-02-29"));
	}
}
